Socket
Socket
Sign inDemoInstall

d3-brush

Package Overview
Dependencies
Maintainers
2
Versions
38
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

d3-brush

Select a one- or two-dimensional region using the mouse or touch.


Version published
Weekly downloads
2.4M
decreased by-14.99%
Maintainers
2
Weekly downloads
 
Created

What is d3-brush?

The d3-brush module is part of the D3.js library and provides tools for creating interactive brushing and linking in visualizations. Brushing allows users to select a region of a chart or graph, which can then be used to highlight or filter data.

What are d3-brush's main functionalities?

Basic Brush

This code sets up a basic brush on an SVG element. When the user interacts with the brush, the 'brushed' function is called, logging the selected region.

const svg = d3.select('svg');
const brush = d3.brush().on('brush', brushed);
svg.append('g').attr('class', 'brush').call(brush);
function brushed(event) {
  const selection = event.selection;
  console.log(selection);
}

Brush with Custom Handle

This code demonstrates how to create a brush with a custom handle size. The handle size is set to 10 pixels.

const svg = d3.select('svg');
const brush = d3.brush().handleSize(10).on('brush', brushed);
svg.append('g').attr('class', 'brush').call(brush);
function brushed(event) {
  const selection = event.selection;
  console.log(selection);
}

Brush with Extent

This code sets up a brush with a specified extent, limiting the brushable area to a 400x400 pixel region.

const svg = d3.select('svg');
const brush = d3.brush().extent([[0, 0], [400, 400]]).on('brush', brushed);
svg.append('g').attr('class', 'brush').call(brush);
function brushed(event) {
  const selection = event.selection;
  console.log(selection);
}

Other packages similar to d3-brush

Keywords

FAQs

Package last updated on 10 Jun 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc